/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */


struct ListNode* reverseList(struct ListNode* head){
    struct ListNode* ss = head;
    int i;
    for(i = 0 ; i < 5000 ; i++){
        if(ss == NULL){
            break;
        }
        ss = ss->next;
    }
    int sz = i;
    struct ListNode* sk = head;
    struct ListNode* sp = NULL;
    struct ListNode* sl = NULL;
    if(sz == 0||sz == 1){
        return head;
    }
    for(i = 1;i <= sz;i++){
        sp = sk->next;
        sk->next = sl;
        sl = sk;
        sk = sp;
    }
    return sl;
}
